Centos7 安装Docker CE
Docker系统有两个程序:docker服务端和docker客户端。其中docker服务端是一个服务进程,管理着所有的容器。docker客户端则扮演着docker服务端的远程控制器,可以用来控制docker的服务端进程。大部分情况下,docker服务端和客户端运行在一台机器上。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 2 Server Version: 18.09.6 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84 runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30 init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-957.5.1.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 3.7GiB Name: vincent-os ID: FPSG:FBC3:LLNU:6TCG:HATE:NZ6J:Z36F:C6PY:KSYW:RGFE:AER6:IFDM Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine
|
安装步骤
卸载旧版本(未安装跳过此步骤)
1 2 3 4 5 6 7 8 9 10
| yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine
|
安装yum插件
1.安装所需的软件包 yum-utils提供了yum-config-manager 效用
1
| yum install -y yum-utils
|
tools for manipulating repositories and extended package management(用于操作存储库和扩展包管理的工具)
2.并需要安装device-mapper-persistent-data和lvm2支持devicemapper存储驱动程序。
1
| yum install -y device-mapper-persistent-data \lvm2
|
3.设置使用国内镜像源
1 2 3
| yum-config-manager \ --add-repo \ https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
|
4.更新更新 yum 软件源缓存
安装Docker-CE
1.设置开机启动并启动Docker
1 2
| systemctl enable docker systemctl start docker
|
2.更新Docker
与安装相似,只需要将install替换为upgrade
1
| yum -y upgrade docker-ce
|
3.镜像加速
找到文件/etc/docker/daemon.json
修改参数
1 2 3 4 5 6 7
| { "registry-mirrors": [ "https://dockerhub.azk8s.cn", "https://reg-mirror.qiniu.com", "http://hub-mirror.c.163.com" ] }
|
4.修改之后重新加载并重启docker
1 2
| systemctl daemon-reload systemctl restart docker
|
重启之后docker info 中的镜像源信息
MacOS 安装Docker
其实最好的是直接安装docker Desktop
Docker 基础命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| # docker docker container --help
# docker --version docker version docker info
# docker run hello-world
# docker image ls
# docker container ls ## 列出所有运行的容器 docker container ls --all ## 列出所有的容器 docker container ls -aq ## 只列出了容器ID
|